Skip to content

Add SQLite FTS5 search for conversations and memory, plus local Skill importer - #380

Merged
d41sys merged 1 commit into
mainfrom
issue-373-fts5-skills
Dec 4, 2026
Merged

d41sys merged 1 commit into
mainfrom
issue-373-fts5-skills

Conversation

@d41sys

@d41sys d41sys commented Dec 4, 2026

Copy link
Copy Markdown
Owner

Summary

Implements SQLite FTS5 full-text search across conversations and memory notes, plus a local Skill importer in Add-ons → Skills:

  1. SQLite FTS5 transcript & memory search (appd/src/store.rs, appd/src/core.rs, PROTOCOL.md):
    • Adds search_items + search_fts (tokenize='trigram', content-synced via triggers) to replace the full-transcript JSON scan in Store::search. Coalesces streamed text deltas at the first piece's seq, stays in sync on append, rewind_transcript, and ON DELETE CASCADE (conversation/bot deletion), and backfills existing app.db files automatically on first open.
    • Falls back cleanly to scanning search_items for 1–2 char queries and cased non-ASCII queries so Unicode case folding and short queries stay exact while ASCII and CJK queries use the FTS5 trigram index.
    • Adds memory_index + memory_fts (tokenize='trigram') and search_memory (text, optional bot or projectId, limit) synced incrementally on write_memory, delete_memory, restore_memory_version, disk edits by bots, and bot/project deletion.
  2. Local Skill importer (appd/src/skills.rs, appd/src/core.rs, window/ui/src/Skills.tsx, native/src/skills.rs, PROTOCOL.md):
    • Adds read-only discover_skills (runs off Core::run via reply_later) scanning standard local skill folders (~/.agents/skills, ~/.claude/skills, ~/.codex/skills, ~/.cursor/skills, ~/.gemini/skills, or BATE_DISCOVER_SKILLS_DIRS in tests), deduplicated by canonical path and validated with proto::skills::parse.
    • Shows discovered skills in an "On this Mac" section in Add-ons → Skills in both window/ui and native (hidden when empty), reusing the existing preview_skill → install sheet → install_skill consent flow.

Closes #373.

Evidence

  • cd window/ui && npm ci && npm run build && npm test: passed (141/141 tests, including stand-in command coverage and UI lint checks).
  • cargo fmt --all --check: passed.
  • cargo clippy --workspace --all-targets --locked -- -D warnings: passed.
  • cargo test --workspace --locked --no-fail-fast: passed, including new unit and integration tests:
    • store::tests::fts5_indexes_transcript_backfill_rewind_cjk_and_memory (verifies coalesced replies, CJK, short/Unicode queries, rewind, backfill on existing DB, memory FTS5, and FTS5 integrity-check).
    • store::tests::deleting_a_bot_or_a_project_leaves_no_row_that_points_at_it (verifies search_items, memory_index, and FTS5 integrity-check after cascade deletes).
    • skills::tests::discover_finds_valid_skills_and_deduplicates_symlinks.
    • service::search_memory_finds_bot_and_project_notes_and_stays_in_sync_on_update_delete_and_disk_writes.
    • service::discover_skills_lists_local_skills_for_preview_and_install.
    • native/tests/addons.rs::discovered_local_skills_appear_under_on_this_mac_and_open_the_install_sheet (existing snapshots unchanged).

Merge Danger

Low-to-medium. Adds SQLite tables/triggers (search_items, search_fts, memory_index, memory_fts) with an idempotent one-time backfill on Store::open when search_items does not yet exist; no existing table schema is altered or dropped, so rollback is safe. search preserves its exact wire format and semantics.

Device decision

  • search_memory: Allowed for paired Devices (ALLOWED_OVER_LAN), matching search, list_memory, and read_memory.
  • discover_skills: Refused (forbidden) for paired Devices (REFUSED_OVER_LAN), matching preview_skill and install_skill — scanning local Mac folders is restricted to Bate's own window on this Mac.

@d41sys
d41sys merged commit 10f72d8 into main Dec 4, 2026
5 checks passed
@d41sys
d41sys deleted the issue-373-fts5-skills branch December 4, 2026 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQLite FTS5 full-text search across conversations and memory, plus local Skill importer

1 participant